﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using CommonTagTime;
using CommonTagTime.Business;
using CommonTagTime.ModelObject;
using System.Web.UI.HtmlControls;

public partial class admin_TrackingChart : SitePage
{
    public class LocationProcess
    {
        public string Name { get; set; }
        public int Total { get; set; }
        public int Complete { get; set; }
        public double PercentComplete { get; set; }
        public LocationProcess()
        {
        }
        public LocationProcess(string _name, int _total, int _complete)
        {
            Name = _name;
            Total = _total;
            Complete = _complete;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
            DrawProcess();
    }
    private void DrawProcess()
    {
        int processW = 100;
        List<LocationProcess> lstData = InitData();
        string s = @"<table cellspacing='2' class='block' cellpadding='0'>";
        string trProcess = "<tr>";
        string trNote = "<tr>";
        foreach (LocationProcess p in lstData)
        {
            double pComplete = (p.Complete * 1.0 / p.Total * 1.0);
            int wComplate = (int)(pComplete * processW);
            if (wComplate < 1)
                wComplate = 1;
            trProcess += @"<td class='location' width='" + processW + @"px'>
                <div class='process' style='width: " + wComplate + @"px;'>
                    &nbsp;
                </div>
                <div class='text'>
                    " + p.Name + @"
                </div>
            </td>";
            trNote += "<td align='center'>" + pComplete * 100 + "%</td>";
        }

        trProcess += "</tr>";
        s += trProcess + trNote + "</table>";
        ltrProcess.Text = s;
    }
    private List<LocationProcess> InitData()
    {
        List<LocationProcess> lst = new List<LocationProcess>();
        LocationProcess p1 = new LocationProcess("Det", 2000, 10);
        lst.Add(p1);
        LocationProcess p2 = new LocationProcess("Cat", 1000, 1000);
        lst.Add(p2);
        LocationProcess p3 = new LocationProcess("QC", 5000, 800);
        lst.Add(p3);
        LocationProcess p4 = new LocationProcess("Design", 5000, 1200);
        lst.Add(p4);
        return lst;
    }
}